package com.lib.common.base.web

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.lib.common.R

/**
 * WebView 错误提示页面
 *
 * @author keanbin
 * @date 2018/8/17
 */
class WebErrorView : RelativeLayout {

    /**
     * 刷新点击回调监听器
     */
    var mOnRefreshClickListener: OnRefreshClickListener? = null

    constructor(context: Context) : super(context) {
        init(context)
    }

    constructor(context: Context, mAttributeSet: AttributeSet) : super(context, mAttributeSet) {
        init(context)
    }

    private fun init(context: Context) {
        View.inflate(context, R.layout.widget_web_error_view, this)

        val promptLl = findViewById<LinearLayout>(R.id.ll_widgetWebErrorView_prompt)
        promptLl.setOnClickListener {
            mOnRefreshClickListener?.onRefreshClick()
        }
    }

    /**
     * 刷新点击回调监听器
     */
    interface OnRefreshClickListener {

        /**
         * 刷新点击回调
         */
        fun onRefreshClick()
    }
}